import type { AddressList, AddressParams } from '@/types/address'
import { request } from '@/utils/request'
// 添加收货地址
// POST
// /member/address
export const addAddressAPI = (data: AddressParams) => {
  return request<{ id: string }>('/member/address', 'POST', data)
}
// 删除收货地址
// DELETE
// /member/address/{id}
export const deleteAddressAPI = (id: string) => {
  return request<{ id: string }>(`/member/address/${id}`, 'DELETE')
}
// 修改收货地址
// PUT
// /member/address/{id}
// isDefault:是否为默认，1为是，0为否 ，注意：此处按照接口实现
export const updateAddressAPI = (id: string, data: AddressParams) => {
  return request<{ id: string }>(`/member/address/${id}`, 'PUT', data)
}
// 获取收货地址详情
// GET
// /member/address/{id}
export const getAddressDetailAPI = (id: string) => {
  return request<AddressList>(`/member/address/${id}`, 'GET')
}
// 获取收货地址列表
// GET
// /member/address
export const getAddressListAPI = () => {
  return request<AddressList[]>('/member/address', 'GET')
}
